<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/vue.js"></script>
    <script src="js/axios.js"></script>
</head>
<body>
<div id="app">

    <button @click="add()" type="button">添加</button>
    <input type="text" v-model="name">
    <input type="button" value="搜索" @click="findPage(1)">

    <table border="1" cellspacing="0">
        <tr>
            <td>id</td>
            <td>用户名</td>
            <td>性别</td>
            <td>年龄</td>
            <td>操作</td>
        </tr>
        <tr v-for="item in page.records">
            <td>{{item.id}}</td>
            <td>{{item.name}}</td>
            <td>{{item.sex}}</td>
            <td>{{item.age}}</td>
            <td>
                <button type="button" @click="del(item.id)">删除</button>
            </td>
        </tr>
    </table>

    <a @click="findPage(1)">首页</a>
    <a @click="findPage(page.current-1)">上一页</a>
    <a @click="findPage(page.current+1)">下一页</a>
    <a @click="findPage(page.pages)">尾页</a>
</div>
</body>
<script>
    new Vue({
        el:"#app",
        data:{
            page:{},
            name:""
        },
        methods:{
            findPage(pageIndex){
                axios.post("/order/findPage?pageIndex="+pageIndex+"&name="+this.name).then(res=>{
                    this.page=res.data;
                })
            },
            add(){
                location.href="add.html";
            },
            del(id){
              axios.get("/order/del?id="+id).then(
                  res=>{
                      location.href="student.html";
                  }
              )
            }
        },
        created(){
            this.findPage(1);
        }
    })
</script>
</html>